#ifndef DATETIME_H
#define DATETIME_H

#include <ctime>
#include <string>
#include <memory>

namespace sh
{
/**
 * @brief:  时间处理工具库
 * @author: sherlock_lht
 */
class DateTime
{
public:
    static long long currentSecond();

    static DateTime currentDateTime();

    static long long tm2Second(tm *tm);

    static std::tm *second2Tm(long long second);

public:
    DateTime();
    DateTime(const DateTime &dateTime);
    explicit DateTime(std::tm *tm);
    explicit DateTime(long long second);
    explicit DateTime(long long second, long long msecond);
    virtual ~DateTime();

    DateTime addDays(int days) const;

    DateTime addSecond(long long seconds) const;

    DateTime addMillSecond(long long msecond) const;

    std::string toString(const std::string &format) const;

    long long toSecond() const;

    long long toMilliSecond() const;

private:
    time_t sec;
    long long int msec;
};
}
#endif //DATETIME_H
